#include "securitytool.h"
#include "../CheckInfor/securityinfor.h"
#include "reslution.h"

SecurityTool* SecurityTool::_instance=nullptr;

SecurityTool* SecurityTool::GetInstance(QObject* parent){
    if(SecurityTool::_instance==nullptr)
        SecurityTool::_instance=new SecurityTool(parent);
    return SecurityTool::_instance;
}

SecurityTool::~SecurityTool(){

}

SecurityTool::SecurityTool(QObject* parent):QObject (parent){

}

std::function<void()> SecurityTool::GetToolFunction(Yzty::SecurityToolCode code){
    std::function<void()> func;
    switch (code)
    {
        case SecurityToolCode::SysShare:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetSysShareDirInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::NetLogin:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetNetLoginInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
         case SecurityToolCode::SysUpdate:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetSysUpdateInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::NetPortInfor:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetNetPortInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::AccountSec:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetAccountSecInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::PwdConfig:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetPwdConfigInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::NetConfig:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetNetConfig();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::SecAudit:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetSecAuditInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::SudoConfig:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetSudoConfigInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::NetFireWall:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetNetFireWallInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::SysProcess:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetSysProcessInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::SysServers:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetSysServerInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::SysKernel:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetSysKernelInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::EmailInfor:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetEmailInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::VirMachine:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetVirMachine();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::DefendSoft:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetDefendSoft();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::UserLogin:
            func=[this,code]()
            {
                QVector<BaceInfor*>&& infors=GetUserLoginInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        case SecurityToolCode::BroHistory:
        {
            func=[this,code](){
                QVector<BaceInfor*>&& infors=this->GetBroHistoryInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };

            break;
        }
        case SecurityToolCode::BroDownload:
        {
            func=[this,code](){
                QVector<BaceInfor*>&& infors=this->GetBroDownloadInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };

            break;
        }
        case SecurityToolCode::BroCollect:
        {
            func=[this,code](){
                QVector<BaceInfor*>&& infors=this->GetBroCollectInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };

            break;
        }

        case SecurityToolCode::BroCookies:
        {
            func=[this,code](){
                QVector<BaceInfor*>&& infors=this->GetBroCookiesInfor();
                SecurityInfor::GetInstance()->SubmitInfor(int(code),infors);
            };
            break;
        }

        default:
            break;
    }
    return func;
}

QVector<Yzty::BaceInfor*> SecurityTool::GetSysShareDirInfor()          //系统共享安全
{
    return Yzty::Reslution::GetInstance()->GetSysShareDirInforFromCmd();
}

QVector<Yzty::BaceInfor*> SecurityTool::GetNetLoginInfor()              //系远程登陆检查
{
    return Yzty::Reslution::GetInstance()->GetNetLoginInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetSysUpdateInfor()             //系统升级文件
{
    return Yzty::Reslution::GetInstance()->GetSysUpdateInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetNetPortInfor()               //系统开放端口
{
    return Yzty::Reslution::GetInstance()->GetNetPortInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetAccountSecInfor()            //账户安全配置
{
    return Yzty::Reslution::GetInstance()->GetAccountSecInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetPwdConfigInfor()             //密码策略配置
{
    return Yzty::Reslution::GetInstance()->GetPwdConfigInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetNetConfig()                  //网络安全配置
{
    return Yzty::Reslution::GetInstance()->GetNetConfigFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetSecAuditInfor()              //安全审计配置
{
    return Yzty::Reslution::GetInstance()->GetSecAuditInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetSudoConfigInfor()            //sudo策略配置
{
    return Yzty::Reslution::GetInstance()->GetSudoConfigInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetNetFireWallInfor()           //防火墙配置
{
    return Yzty::Reslution::GetInstance()->GetNetFireWallInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetSysProcessInfor()            //系统进程信息
{
    return Yzty::Reslution::GetInstance()->GetSysProcessInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetSysServerInfor()            //系统服务信息
{
    return Yzty::Reslution::GetInstance()->GetSysServerInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetSysKernelInfor()             //系统加载内核
{
    return Yzty::Reslution::GetInstance()->GetSysKernelInforFromCmd();
}

QVector<Yzty::BaceInfor*> SecurityTool::GetEmailInfor()                //邮件客户端
{
    return Yzty::Reslution::GetInstance()->GetEmailInforFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetVirMachine()                 //虚拟机安装
{
    return Yzty::Reslution::GetInstance()->GetVirMachineFromCmd();

}

QVector<Yzty::BaceInfor*> SecurityTool::GetDefendSoft()                 //杀毒软件防护
{
    return Yzty::Reslution::GetInstance()->GetDefendSoftFromCmd();

}

QVector<Yzty::BaceInfor*>SecurityTool::GetUserLoginInfor()
{
    return Yzty::Reslution::GetInstance()->GetUserLoginInforFromCmd();
}

QVector<BaceInfor*> SecurityTool::GetBroHistoryInfor()
{
    return Reslution::GetInstance()->GetBroHistoryInforFromCmd();

}

QVector<BaceInfor*> SecurityTool::GetBroDownloadInfor()
{
    return Reslution::GetInstance()->GetBroDownloadInforFromCmd();

}

QVector<BaceInfor*> SecurityTool::GetBroCollectInfor()
{
    return Reslution::GetInstance()->GetBroCollectInforFromCmd();

}

QVector<BaceInfor*> SecurityTool::GetBroCookiesInfor(){
    return  Reslution::GetInstance()->GetBroCookiesInforFromCmd();
}
